package com.mikao.service.impl;

import com.mikao.constant.ErrorCode;
import com.mikao.dao.FeedbackDao;
import com.mikao.dto.bo.FeedbackForm;
import com.mikao.dto.vo.BaseResult;
import com.mikao.entity.Feedback;
import com.mikao.service.FeedbackService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

/**
 * @author kenny
 */

@Service
@Slf4j
public class FeedbackServiceImpl implements FeedbackService {

    private FeedbackDao feedbackDao;

    public FeedbackServiceImpl(FeedbackDao feedbackDao) {
        this.feedbackDao = feedbackDao;
    }

    @Override
    public BaseResult addFeedback(Long userId, FeedbackForm feedbackForm) {
        Feedback feedback = new Feedback();
        BeanUtils.copyProperties(feedbackForm, feedback);
        feedback.setUserId(userId);
        feedbackDao.saveAndFlush(feedback);
        return new BaseResult(ErrorCode.SUCCESS.getCode(), ErrorCode.SUCCESS.getMsg());
    }
}
